/***************************************************************************************************
 *
 * Project: HZFlashcards
 *
 * Class: FlashcardsMenuBar
 *
 * File name: FlashcardsMenuBar.java
 *
 * Created: Aug 22, 2007
 *
 *    $URL: file:///C:/Documents%20and%20Settings/All%20Users/Documents/Development/Eclipse_SVNRepository/HZFlashcards/src/com/eastmountain/chinese/gui/FlashcardsMenuBar.java $:
 *
 *    $Rev: 75 $:
 *    $Date: 2007-09-30 14:11:59 -0400 (Sun, 30 Sep 2007) $:
 *
 *    $LastChangedBy: ChaoChou $:
 *
 **************************************************************************************************/

package com.eastmountain.chinese.gui.controllers;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.InputStream;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.KeyStroke;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalTheme;
import javax.swing.plaf.metal.OceanTheme;

import com.eastmountain.chinese.common.FlashCardLessonSet;
import com.eastmountain.chinese.db.exceptions.DBAccessException;
import com.eastmountain.chinese.fonts.ChineseFontChooser;
import com.eastmountain.chinese.gui.FileChooser;
import com.eastmountain.chinese.lessontree.LessonTreePanel;
import com.eastmountain.chinese.observable.HZFlashcardsDataModel;
import com.eastmountain.chinese.themes.BigContrastMetalTheme;
import com.eastmountain.chinese.themes.CharcoalTheme;
import com.eastmountain.chinese.themes.ContrastMetalTheme;
import com.eastmountain.chinese.themes.DemoMetalTheme;
import com.eastmountain.chinese.themes.GreenMetalTheme;
import com.eastmountain.chinese.themes.KhakiMetalTheme;
import com.eastmountain.chinese.themes.OxideTheme;
import com.eastmountain.util.logging.LoggerUtils;

@SuppressWarnings("serial" )
public class FlashcardsMenuBar extends JMenuBar implements Observer, ActionListener, ItemListener {

    private HZFlashcardsDataModel hzFlashcardsDataModel;

    private JDialog dialog;

    private String newline = "\n";
    
    //  Used to create button comands to differentiate
    //  buttons whose label are ambiguos. 
    //  For example "Open/Review List" and
    //  "Save/Review List".
    
    private static String openSuffix = "Open";
    private static String saveSuffix = "Save";
    
    /**************************************************
     * 
     *  File menu
     * 
     **************************************************/
    
    private static final String FILE_MENU = "File";

    // File actions
    
    private static final String NEW_ACTION = "New";

    private static final String OPEN_ACTION = "Open";

    private static final String OPEN_WORKING_SET_ACTION = "Working Set..." + "\u0013";
    private static final String OPEN_REVIEW_LIST_ACTION = "Review List...";

    private static final String OPEN_WORKING_SET_COMMAND = "Open Working Set...";
    private static final String OPEN_REVIEW_LIST_COMMAND = "Open Review List...";
    
    private static final String SAVE_ACTION = "Save";

    private static final String SAVE_WORKING_SET_ACTION = "Working Set...";
    private static final String SAVE_REVIEW_LIST_ACTION = "Review List...";

    private static final String SAVE_WORKING_SET_COMMAND = "Save Working Set...";
    private static final String SAVE_REVIEW_LIST_COMMAND = "Save Review List...";

    private static final String PRINT_ACTION = "Print...";
    
    /**************************************************
     * 
     *  Edit menu
     * 
     **************************************************/

    private static final String EDIT_MENU = "Edit";

    // Edit actions
    
    /**************************************************
     * 
     *  View menu
     * 
     **************************************************/

    private static final String VIEW_MENU = "View";

    // View actions

    private static final String SLIDE_SHOW_ACTION = "Slide Show";
    private static final String WORD_XRF_ACTION = "Word XRF";
    private static final String CHARACTER_CONTENT_ACTION = "Character Content";
    
    private static final String CHARACTERS_ACTION = "Characters";
    private static final String WORDS_ACTION = "Words";

    private static final String SOUND_ACTION = "Soind Drills";
    private static final String TONES_ACTION = "Tones";
    private static final String INITIALS_ACTION = "Initials";
    private static final String RHYMES_ACTION = "Rhymes";
    
    /**************************************************
     * 
     *  Format menu
     * 
     **************************************************/

    private static final String FORMAT_MENU = "Format";

    // Format actions
    
    private static final String FONTS_ACTION = "Fonts...";
    
    /**************************************************
     * 
     *  Window menu
     * 
     **************************************************/

    private static final String WINDOW_MENU = "Window";

    // Window actions
    
    /**************************************************
     * 
     *  Help menu
     * 
     **************************************************/

    private static final String HELP_MENU = "Help";

    // Help Actions

    private static String projectName = "hzflashcards";
    protected static final Logger logger = LoggerUtils.setUpLogger( projectName );

    // Help actions

    /*************************************************
    *
    *   FlashcardsMenuBar
    *
    **************************************************/

    public FlashcardsMenuBar() {

        hzFlashcardsDataModel = HZFlashcardsDataModel.getInstance();
        hzFlashcardsDataModel.addObserver( this );

        constructMenus();

    }

    public void constructMenus() {

        // TODO Finish menu stuff

        buildOpenMenu();

        buildEditMenu();

        buildViewMenu();

        buildFormatMenu();

        buildThemeMenu();

        buildWindowMenu();
        
        buildHelpMenu();
        
/*
        // An experiment

        //add( Box.createHorizontalGlue() );

        //menu = new JMenu();
        //hanZiCounterPanel = new HanZiCounterPanel();
        //add( hanZiCounterPanel );

        //add( Box.createRigidArea( new Dimension( 5, 0 ) ) );
*/
        
    }
	
	/**************************************************
     *   File menu - buildOpenMenu
     **************************************************/

	private void buildOpenMenu() {
		
		JMenu menu;
		JMenu subMenu;
		JMenuItem menuItem;

        menu = new JMenu( FlashcardsMenuBar.FILE_MENU );
        menu.setMnemonic( KeyEvent.VK_F );
        menu.getAccessibleContext().setAccessibleDescription(
                                        "The only menu in this program that has menu items" );
        add( menu );

        // New menu

        menuItem = new JMenuItem( FlashcardsMenuBar.NEW_ACTION );
        menuItem.setMnemonic( KeyEvent.VK_N );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_N, ActionEvent.ALT_MASK ) );
        menuItem.addActionListener( this );
        menu.add( menuItem );

        // NOTE that some OPEN and SAVE stuff is shared
        //      and that is why action command is used to
        //      differentiate OPEN from SAVE.

        
        // Open menu

        subMenu = new JMenu( FlashcardsMenuBar.OPEN_ACTION );
        subMenu.setMnemonic( KeyEvent.VK_O );

        menuItem = new JMenuItem( FlashcardsMenuBar.OPEN_WORKING_SET_ACTION );
        menuItem.setActionCommand( OPEN_WORKING_SET_COMMAND );
        menuItem.addActionListener( this );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_1, ActionEvent.ALT_MASK ) );
        subMenu.add( menuItem );

        menuItem = new JMenuItem( FlashcardsMenuBar.OPEN_REVIEW_LIST_ACTION );
        menuItem.setActionCommand( OPEN_REVIEW_LIST_COMMAND );
        menuItem.addActionListener( this );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_2, ActionEvent.ALT_MASK ) );
        subMenu.add( menuItem );

        menu.add( subMenu );

        // Save submenu

        subMenu = new JMenu( FlashcardsMenuBar.SAVE_ACTION );
        subMenu.setMnemonic( KeyEvent.VK_S );

        menuItem = new JMenuItem( FlashcardsMenuBar.SAVE_WORKING_SET_ACTION );
        menuItem.setActionCommand( SAVE_WORKING_SET_COMMAND );
        menuItem.addActionListener( this );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_1, ActionEvent.ALT_MASK ) );
        subMenu.add( menuItem );

        menuItem = new JMenuItem( FlashcardsMenuBar.SAVE_REVIEW_LIST_ACTION );
        menuItem.setActionCommand( SAVE_REVIEW_LIST_COMMAND );
        menuItem.addActionListener( this );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_2, ActionEvent.ALT_MASK ) );
        subMenu.add( menuItem );

        menu.add( subMenu );

        menuItem = new JMenuItem( FlashcardsMenuBar.PRINT_ACTION );
        menuItem.setMnemonic( KeyEvent.VK_O );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_O, ActionEvent.ALT_MASK ) );
        menuItem.addActionListener( this );
        menu.add( menuItem );
	}
	
	/**************************************************
     *   Edit menu - buildEditMenu
     **************************************************/

	private void buildEditMenu() {
		
		JMenu menu;

        menu = new JMenu( FlashcardsMenuBar.EDIT_MENU );
        menu.setMnemonic( KeyEvent.VK_E );
        menu.getAccessibleContext().setAccessibleDescription( "This menu does nothing" );
        add( menu );
	}
	
	/**************************************************
     *   View menu - buildViewMenu
     **************************************************/

	private void buildViewMenu() {
		
		JMenu menu;
        JMenu subMenu;
		JMenuItem menuItem;
		JRadioButtonMenuItem rbMenuItem;

        menu = new JMenu( FlashcardsMenuBar.VIEW_MENU );
        menu.setMnemonic( KeyEvent.VK_V );
        menu.getAccessibleContext().setAccessibleDescription( "This menu does nothing" );
        add( menu );

        // a group of JMenuItems for View

        menuItem = new JMenuItem( FlashcardsMenuBar.SLIDE_SHOW_ACTION );
        menuItem.setMnemonic( KeyEvent.VK_L );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_L, ActionEvent.ALT_MASK ) );
        menuItem.addActionListener( this );
        menu.add( menuItem );

        menuItem = new JMenuItem( FlashcardsMenuBar.WORD_XRF_ACTION );
        menuItem.setMnemonic( KeyEvent.VK_W );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_W, ActionEvent.ALT_MASK ) );
        menuItem.setToolTipText( "Display character to word cross-reference" );
        menuItem.addActionListener( this );
        menuItem.addItemListener( this );
        menu.add( menuItem );

        menuItem = new JMenuItem( FlashcardsMenuBar.CHARACTER_CONTENT_ACTION );
        menuItem.setMnemonic( KeyEvent.VK_C );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_C, ActionEvent.ALT_MASK ) );
        menuItem.setToolTipText( "Display characters in the current word" );
        menuItem.addActionListener( this );
        menuItem.addItemListener( this );
        menu.add( menuItem );

        menu.addSeparator();

        ButtonGroup group = new ButtonGroup();

        rbMenuItem = new JRadioButtonMenuItem( FlashcardsMenuBar.CHARACTERS_ACTION );
        rbMenuItem.addActionListener( this );
        rbMenuItem.addItemListener( this );
        // rbMenuItem.setAccelerator(KeyStroke.getKeyStroke(
        // KeyEvent.VK_C, ActionEvent.ALT_MASK));
        rbMenuItem.setMnemonic( KeyEvent.VK_C );
        rbMenuItem.setSelected( true );
        group.add( rbMenuItem );
        menu.add( rbMenuItem );

        rbMenuItem = new JRadioButtonMenuItem( FlashcardsMenuBar.WORDS_ACTION );
        rbMenuItem.addActionListener( this );
        rbMenuItem.addItemListener( this );
        rbMenuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_W, ActionEvent.ALT_MASK ) );
        //rbMenuItem.setSelected( true );
        rbMenuItem.setMnemonic( KeyEvent.VK_W );
        group.add( rbMenuItem );
        menu.add( rbMenuItem );
        
        
        // Sounds menu

        subMenu = new JMenu( FlashcardsMenuBar.SOUND_ACTION );
        subMenu.setMnemonic( KeyEvent.VK_O );

        menuItem = new JMenuItem( FlashcardsMenuBar.TONES_ACTION );
        menuItem.addActionListener( this );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_1, ActionEvent.ALT_MASK ) );
        subMenu.add( menuItem );

        menuItem = new JMenuItem( FlashcardsMenuBar.INITIALS_ACTION );
        menuItem.addActionListener( this );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_2, ActionEvent.ALT_MASK ) );
        subMenu.add( menuItem );

        menuItem = new JMenuItem( FlashcardsMenuBar.RHYMES_ACTION );
        menuItem.addActionListener( this );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_2, ActionEvent.ALT_MASK ) );
        subMenu.add( menuItem );

        menu.add( subMenu );


	}
	
	/**************************************************
     *   Format menu - buildFormatMenu
     **************************************************/

	private void buildFormatMenu() {
		
		JMenu menu;
		JMenuItem menuItem;

        menu = new JMenu( FlashcardsMenuBar.FORMAT_MENU );
        menu.setMnemonic( KeyEvent.VK_V );
        menu.getAccessibleContext().setAccessibleDescription( "Controls font" );
        add( menu );

        // a group of JMenuItems for Format

        menuItem = new JMenuItem( FlashcardsMenuBar.FONTS_ACTION );
        menuItem.setMnemonic( KeyEvent.VK_L );
        menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_L, ActionEvent.ALT_MASK ) );
        menuItem.addActionListener( this );
        menu.add( menuItem );
	}
	
	/**************************************************
     *   Theme menu - buildThemeMenu
     **************************************************/

	private void buildThemeMenu() {
		
		//  Theme menu
        //  TODO move to preferences panel

        // load a theme from a text file

        MetalTheme myTheme = null;

        try {

            InputStream istream = getClass().getResourceAsStream( "./resources/MyTheme.theme" );
            //myTheme = new PropertiesMetalTheme( istream );

        } catch ( NullPointerException e ) {

            System.out.println( "Unable to load theme from properties.  " + e );
            e.printStackTrace();

        }


        // build an array of themes
        MetalTheme[] themes = { new OceanTheme(), new DefaultMetalTheme(),
                               new CharcoalTheme(),
                               new GreenMetalTheme(),
                               new OxideTheme(),
                               new KhakiMetalTheme(),
                               new DemoMetalTheme(),
                               new ContrastMetalTheme(),
                               new BigContrastMetalTheme(),
                               myTheme
                               };

        // put the themes in a menu

        JMenu themeMenu = new MetalThemeMenu( "Theme", themes );

        add( themeMenu );
	}
	
	/**************************************************
     *   Window menu - buildWindowMenu
     **************************************************/

	private void buildWindowMenu() {
		
		JMenu menu;
		
		// Build second menu in the menu bar

        menu = new JMenu( FlashcardsMenuBar.WINDOW_MENU );
        menu.setMnemonic( KeyEvent.VK_W );
        menu.getAccessibleContext().setAccessibleDescription( "This menu does nothing" );
        add( menu );
        
	}
	
	/**************************************************
     *   Help menu - buildHelpMenu
     **************************************************/

	private void buildHelpMenu() {
		
		JMenu menu;

        menu = new JMenu( FlashcardsMenuBar.HELP_MENU );
        menu.setMnemonic( KeyEvent.VK_H );
        menu.getAccessibleContext().setAccessibleDescription( "This menu does nothing" );
        add( menu );
	}

    public void actionPerformed( ActionEvent e ) {

        LessonTreePanel lessonTreePanel = null;
    	int[] lessonNumbers = null;
    	FlashCardLessonSet flashCardLessonSet;
    	
    	File openFile = null;
    	File saveFile = null;
    	
        JMenuItem item = (JMenuItem) e.getSource();

        /**************************************************
         *   File menu
         **************************************************/

        /**************************************************
         *   New actions
         **************************************************/

        if ( FlashcardsMenuBar.NEW_ACTION.equals( item.getText() ) ) {

            lessonTreePanel = new LessonTreePanel();
            
            try {

                lessonNumbers = lessonTreePanel.showDialog();

                if ( ! ( lessonNumbers == null ) ) {
                
                logger.log( Level.INFO, "lessonNumbers: " + lessonNumbers );
                
                flashCardLessonSet
                    = hzFlashcardsDataModel.getChineseElementsByLessonNumberList( lessonNumbers );
                
                logger.log( Level.INFO, "flashCardLessonSet size: " + flashCardLessonSet.size() );
                
                hzFlashcardsDataModel.setChanged();
                hzFlashcardsDataModel.notifyObservers( flashCardLessonSet );
                
                } else {     
                    
                    logger.log( Level.INFO, "No action taken in New Dialog Box." );
   
                }
                
            } catch (DBAccessException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            
            System.out.println( "***** returned from dialog" );

            /**************************************************
             *   Open actions
             **************************************************/

            //  TODO take care of active/disabled
            
        } else if ( FlashcardsMenuBar.OPEN_WORKING_SET_COMMAND.equals( item.getActionCommand() ) ) {

            System.out.println( "@@@ OPEN_WORKING_SET_COMMAND @@@" );
            
            openFile = getFileName( JFileChooser.OPEN_DIALOG,
                                    "Open Working Set" );

            flashCardLessonSet
                = hzFlashcardsDataModel.openLessonWorkingSet( saveFile );
            
            hzFlashcardsDataModel.setChanged();
            hzFlashcardsDataModel.notifyObservers( flashCardLessonSet );

        } else if ( FlashcardsMenuBar.OPEN_REVIEW_LIST_COMMAND.equals( item.getActionCommand() ) ) {

            System.out.println( "@@@ OPEN_REVIEW_LIST_COMMAND @@@" );
            
            openFile = getFileName( JFileChooser.OPEN_DIALOG,
                                    "Open Review List" );

            flashCardLessonSet 
                = hzFlashcardsDataModel.openReviewList( openFile );
            
            hzFlashcardsDataModel.setChanged();
            hzFlashcardsDataModel.notifyObservers( flashCardLessonSet );

            /**************************************************
             *   Save actions
             **************************************************/

        } else if ( FlashcardsMenuBar.SAVE_WORKING_SET_COMMAND.equals( item.getActionCommand() ) ) {

            System.out.println( "@@@ SAVE_WORKING_SET_COMMAND @@@" );
                        
            saveFile = getFileName( JFileChooser.SAVE_DIALOG,
                                    "Save Working Set" );

            hzFlashcardsDataModel.saveLessonWorkingSet( saveFile );

        } else if ( FlashcardsMenuBar.SAVE_REVIEW_LIST_COMMAND.equals( item.getActionCommand() ) ) {

            System.out.println( "@@@ SAVE_REVIEW_LIST_COMMAND @@@" );
            
            saveFile = getFileName( JFileChooser.SAVE_DIALOG,
                                    "Save Review List" );

            hzFlashcardsDataModel.saveReviewList( saveFile );

        } else if ( FlashcardsMenuBar.PRINT_ACTION.equals( item.getText() ) ) {

            hzFlashcardsDataModel.printReviewList();

        /**************************************************
         *   View menu
         **************************************************/

        /**************************************************
         *   View actions
         **************************************************/

        } else if ( FlashcardsMenuBar.SLIDE_SHOW_ACTION.equals( item.getText() ) ) {
        	
        	hzFlashcardsDataModel.startSlideShow();

        } else if ( FlashcardsMenuBar.WORD_XRF_ACTION.equals( item.getText() ) ) {

            System.out.println( "======= actionPerformed() - WORD_XRF  !!!!" );

            hzFlashcardsDataModel.printCharacterWordXRFList();

        } else if ( FlashcardsMenuBar.CHARACTER_CONTENT_ACTION.equals( item.getText() ) ) {

            System.out.println( "======= actionPerformed() - CHARACTER_CONTENT  !!!!" );

            hzFlashcardsDataModel.printLWordCharacterBreakdownList();

        } else if ( FlashcardsMenuBar.CHARACTERS_ACTION.equals( item.getText() ) ) {

            hzFlashcardsDataModel.setView( HZFlashcardsDataModel.VIEW_CHARACTERS );

        } else if ( FlashcardsMenuBar.WORDS_ACTION.equals( item.getText() ) ) {

            hzFlashcardsDataModel.setView( HZFlashcardsDataModel.VIEW_WORDS );
          
        } else if ( FlashcardsMenuBar.TONES_ACTION.equals( item.getText() ) ) {

            System.out.println( "@@@ TONES @@@" );

            //hzFlashcardsDataModel.setView( HZFlashcardsDataModel.VIEW_WORDS );
            
        } else if ( FlashcardsMenuBar.INITIALS_ACTION.equals( item.getText() ) ) {

            System.out.println( "@@@ INITIALS @@@" );

            //hzFlashcardsDataModel.setView( HZFlashcardsDataModel.VIEW_WORDS );
            
        } else if ( FlashcardsMenuBar.RHYMES_ACTION.equals( item.getText() ) ) {

            System.out.println( "@@@ RHYMES @@@" );

            hzFlashcardsDataModel.setView( HZFlashcardsDataModel.VIEW_WORDS );

        /**************************************************
         *   Format menu
         **************************************************/

        /**************************************************
         *   Format actions
         **************************************************/

        } else if ( FlashcardsMenuBar.FONTS_ACTION.equals( item.getText() ) ) {

            System.out.println( "======= actionPerformed() - FONTS_ACTION_XRF  !!!!" );

            Font font = ChineseFontChooser.showDialog( "Chinese Font Chooser", null );

            if ( font != null ) {
                
                hzFlashcardsDataModel.setActiveHanZiFont( font );

                hzFlashcardsDataModel.setChanged();
                hzFlashcardsDataModel.notifyObservers( font );

            }
        }

        String s = "Action event detected." + newline + "    Event source: " + item.getText()
                                        + " (an instance of "
                                        + item.getClass().getSimpleName() + ")";
        System.out.println( s );

    }

    public void itemStateChanged( ItemEvent e ) {

        JMenuItem item = (JMenuItem) e.getSource();
        String s = "Item event detected."
                                        + newline
                                        + "    Event source: "
                                        + item.getText()
                                        + " (an instance of "
                                        + item.getClass().getSimpleName()
                                        + ")"
                                        + newline
                                        + "    New state: "
                                        + (e.getStateChange() == ItemEvent.SELECTED ? "selected"
                                                                        : "unselected");
        System.out.println( s );

    }

    private File getFileName( int dialogType, String fileType ) {

        int returnVal = -1;
        File outputFile = null;

            FileChooser fileChooser = new FileChooser( dialogType, fileType );

            switch ( dialogType ) {
                
                case JFileChooser.OPEN_DIALOG:
                    
                    returnVal = fileChooser.showOpenDialog( null );
                    
                    break;
                    
                case JFileChooser.SAVE_DIALOG:
                    
                    returnVal = fileChooser.showSaveDialog( null );
                    
                    break;

                default:
                    
                    System.out.println( "\nError Opening JFileChooser for Review \n" );
                    
                    break;
                
            }           
            

            if ( returnVal == JFileChooser.APPROVE_OPTION) {

                outputFile = fileChooser.getSelectedFile();

                System.out.println( "\nOpening/Saving : " + outputFile + "\n" );

            } else {

                System.out.println( "\nOpen command cancelled by user.\n" );

            }

            return outputFile;

    }

    protected static ImageIcon createImageIcon( String path ) {

        java.net.URL imgURL = FlashcardsMenuBar.class.getResource( path );

        if ( imgURL != null ) {

            return new ImageIcon( imgURL );

        } else {

            System.err.println( "Couldn't find file: " + path );
            return null;

        }

    }

    public void update( Observable o, Object arg ) {

        /*************************************************
         *
         *   update
         *
         *************************************************/

    }

}
